package cn.yaboya.basic.config;

import cn.yaboya.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration // 当前类是一个配置类，类似于之前的 SpringXxx.xml
public class LoginConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor) // 指定我们自己的登录拦截器
                .addPathPatterns("/**") // 设置拦截所有
                .excludePathPatterns("/login/**") // 设置放行路径
                .excludePathPatterns("/loginPhone/**") // 设置放行路径
                .excludePathPatterns("/fastDfs/**")
                .excludePathPatterns("/verifyCode/**")
                .excludePathPatterns("/shop/settlement")
                .excludePathPatterns("/user/register/**");
    }
}
